function reportError(request)
{
	alert('Sorry. There was an error.');
}

//------------------ Open Index page ---------------------------------
function ChangeRetailer(DivId)
{
	if($(DivId).innerHTML != '') {
		Effect.toggle(DivId,'slide');
		return false;
	}
	else {
		$(DivId).innerHTML = '<p>Loading...</p>';
	}
	var url = app_path + 'main.php?do=OrderItem&action=ChangeRetailer';
	var myAjax = new Ajax.Updater(
	{success:DivId},
	url,
	{
		method: 'get',
		parameters: '',
		onComplete:Effect.toggle(DivId,'slide'),
		onFailure: reportError
	});
}

function ChangeTemplate(mystring)
{
	//alert(mystring); 
	var mySplitResult = mystring.split("_");
	var EmailTemplateId=mySplitResult[0];
	var OrderItemId=mySplitResult[1];
	//alert(EmailTemplateId);
	//alert(OrderItemId);
	//return false;
	var url = app_path + 'main.php?do=OrderItem&action=ChangeEmailsTemplet&EmailTemplateId='+EmailTemplateId+'&OrderItemId='+OrderItemId;
	//var url='view/EmailsMidAjax.php?';
	var myAjax = new Ajax.Updater(
	{success:'TemplateId'},
	url,
	{
		method: 'get',
		parameters: '',
		onFailure: reportError
	});
}